home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / ActionWall.as next >
Text File  |  2013-04-24  |  4KB  |  119 lines

  1. class ActionWall extends State
  2. {
  3.    static var sLINKAGE_NAME_DOOR = "mcDoor90";
  4.    static var sLINKAGE_NAME_DOOR_INVERSE = "mcDoor90Inverse";
  5.    static var sLINKAGE_NAME_REVOLVER = "mcRevolver";
  6.    static var sLINKAGE_NAME_SLIDE_H = "mcSlideH";
  7.    static var sLINKAGE_NAME_SLIDE_V = "mcSlideV";
  8.    static var sSTATE_OPENED = "Opened";
  9.    static var sSTATE_CLOSED = "Closed";
  10.    static var sSTATE_OPENING = "Opening";
  11.    static var sSTATE_CLOSING = "Closing";
  12.    static var nCOUNTER = 0;
  13.    static var nMIN_TIME = 40;
  14.    static var nMAX_TIME = 120;
  15.    function ActionWall(_nType, _nX, _nY, _xScl)
  16.    {
  17.       super(CTRLGame.getRef().mcRef.attachMovie(this.getLinkage(_nType),"mcMovingWall" + ActionWall.nCOUNTER,CTRLGame.getRef().calculateDepth(_nY,CTRLGame.nMOVING_WALL_ADD + ActionWall.nCOUNTER)));
  18.       ActionWall.nCOUNTER = ActionWall.nCOUNTER + 1;
  19.       this.mcRef._x = _nX;
  20.       this.mcRef._y = _nY;
  21.       this.mcRef._xscale = _xScl;
  22.       var _loc7_ = CTRLGame.getRef().Maze.getTabIndex(this.mcRef._x,this.mcRef._y);
  23.       if(CTRLGame.getRef().Maze.isPieceFlipped(_loc7_))
  24.       {
  25.          this.mcRef._xscale = - this.mcRef._xscale;
  26.       }
  27.       this.nType = _nType;
  28.       this.setState(ActionWall.sSTATE_CLOSED);
  29.       this.nSwitchRate = Math.round(Math.random() * (ActionWall.nMAX_TIME - ActionWall.nMIN_TIME)) + ActionWall.nMIN_TIME;
  30.       this.nLife = this.nSwitchRate;
  31.    }
  32.    function cleanUp()
  33.    {
  34.       super.cleanUp();
  35.       this.mcRef.swapDepths(7777);
  36.       this.mcRef.removeMovieClip();
  37.    }
  38.    function get Type()
  39.    {
  40.       return this.nType;
  41.    }
  42.    function get Ref()
  43.    {
  44.       return this.mcRef;
  45.    }
  46.    function manageStaticState(_sNextState)
  47.    {
  48.       if(!Controller.getRef().isPaused() && !CTRLGame.getRef().Screen.isInMiniGame())
  49.       {
  50.          if(this.nLife > 0)
  51.          {
  52.             this.nLife = this.nLife - 1;
  53.          }
  54.          if(this.nLife == 0)
  55.          {
  56.             if(this.nType == CTRLGame.nREVOLVER_WALL)
  57.             {
  58.                if(CTRLGame.getRef().isOkayToTurnRevolver(this.mcRef.mcHit2,this.mcRef.mcHit2More))
  59.                {
  60.                   this.setState(_sNextState);
  61.                   this.nLife = this.nSwitchRate;
  62.                }
  63.             }
  64.             else if(CTRLGame.getRef().isOkayToTurn(this.mcRef.mcHit2))
  65.             {
  66.                this.setState(_sNextState);
  67.                this.nLife = this.nSwitchRate;
  68.             }
  69.          }
  70.       }
  71.    }
  72.    function getLinkage(_nType)
  73.    {
  74.       if(_nType == CTRLGame.nTURN_WALL)
  75.       {
  76.          var _loc3_ = ActionWall.sLINKAGE_NAME_DOOR;
  77.       }
  78.       else if(_nType == CTRLGame.nREVOLVER_WALL)
  79.       {
  80.          _loc3_ = ActionWall.sLINKAGE_NAME_REVOLVER;
  81.       }
  82.       else if(_nType == CTRLGame.nSLIDE_WALL_H)
  83.       {
  84.          _loc3_ = ActionWall.sLINKAGE_NAME_SLIDE_H;
  85.       }
  86.       else if(_nType == CTRLGame.nTURN_WALL_INVERSE)
  87.       {
  88.          _loc3_ = ActionWall.sLINKAGE_NAME_DOOR_INVERSE;
  89.       }
  90.       else
  91.       {
  92.          _loc3_ = ActionWall.sLINKAGE_NAME_SLIDE_V;
  93.       }
  94.       return _loc3_;
  95.    }
  96.    function Opened()
  97.    {
  98.       this.manageStaticState(ActionWall.sSTATE_CLOSING);
  99.    }
  100.    function Closing()
  101.    {
  102.       if(this.stateFinished())
  103.       {
  104.          this.setState(ActionWall.sSTATE_CLOSED);
  105.       }
  106.    }
  107.    function Closed()
  108.    {
  109.       this.manageStaticState(ActionWall.sSTATE_OPENING);
  110.    }
  111.    function Opening()
  112.    {
  113.       if(this.stateFinished())
  114.       {
  115.          this.setState(ActionWall.sSTATE_OPENED);
  116.       }
  117.    }
  118. }
  119.